package com.jl15988.chainlog.util;

/**
 * Chain Log 工具
 *
 * @author Jalon
 * @since 2025/9/30 14:45
 **/
public class ChainLogUtil {

    /**
     * 检查是否应该排除监控
     *
     * @param className       类名
     * @param methodName      方法名
     * @param excludePackages 排除的包
     * @param excludeClasses  排除的类
     * @param excludeMethods  排除的方法
     * @return 是否排除
     */
    public static boolean shouldExclude(String className, String methodName,
                                        java.util.List<String> excludePackages,
                                        java.util.List<String> excludeClasses,
                                        java.util.List<String> excludeMethods) {
        // 检查包路径排除
        if (excludePackages != null) {
            for (String excludePackage : excludePackages) {
                if (className.startsWith(excludePackage)) {
                    return true;
                }
            }
        }

        // 检查类名排除
        if (excludeClasses != null) {
            for (String excludeClass : excludeClasses) {
                if (className.equals(excludeClass) || className.endsWith("." + excludeClass)) {
                    return true;
                }
            }
        }

        // 检查方法名排除
        if (excludeMethods != null) {
            for (String excludeMethod : excludeMethods) {
                if (methodName.equals(excludeMethod)) {
                    return true;
                }
            }
        }

        return false;
    }
}
